import React from 'react'
import * as Router from 'react-router-dom'
import * as UI from 'antd-mobile'
import * as ICON from 'antd-mobile-icons'
import request from '@/services/request'
import Cookie from 'react-cookies'

// 在全局React身上做一个自定义属性的设置
React.Router = Router
React.UI = UI
React.ICON = ICON
React.HTTP = request
React.Cookie = Cookie

// 成功提醒方法
React.success = (msg: string, callback?: Function) => {
  React.UI.Toast.show({
    icon: 'success',
    content: msg,
    duration: 1500,
    afterClose: callback ? callback : () => {
      React.navigate(-1)
    }
  })
}

// 失败提醒方法
React.error = (msg: string, callback?: Function) => {
  React.UI.Toast.show({
    icon: 'fail',
    content: msg,
    duration: 1500,
    afterClose: callback ? callback : () => {
      React.navigate(-1)
    }
  })
}

export default {}
